<template>
  <div class="container">
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="120px"
      label-position="left"
    >
      <el-form-item label="内心独白">
        <el-input type="textarea" v-model="form.soliloquy"></el-input>
      </el-form-item>
      <el-form-item label="喜欢的一道菜">
        <el-input v-model="form.dish"></el-input>
      </el-form-item>
      <el-form-item label="喜欢的一位名人">
        <el-input v-model="form.celebrity"></el-input>
      </el-form-item>
      <el-form-item label="喜欢的一首歌">
        <el-input v-model="form.song"></el-input>
      </el-form-item>
      <el-form-item label="喜欢的一本书">
        <el-input v-model="form.book"></el-input>
      </el-form-item>
      <el-form-item label="喜欢做的事">
        <el-input v-model="form.something"></el-input>
      </el-form-item>
      <el-form-item>
        <div class="bottom">
          <div class="btn submit" @click="onSubmit">下一步</div>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "IndexView",
  data() {
    return {
      form: {},
      rules: {
        native_place: [
          { required: true, message: "请选择", trigger: "change" },
        ],
        nickname: [{ required: true, message: "请选择", trigger: "blur" }],
        weight: [{ required: true, message: "请输入", trigger: "blur" }],
        height: [{ required: true, message: "请输入", trigger: "blur" }],
      },
      config: {},
      area: [],
    };
  },
  props: {
    info: {
      default: {},
    },
  },
  mounted() {
    this.form = this.info;
    this.getConfig();
    this.getArea();
  },
  methods: {
    getConfig() {
      this.$post("member/config").then((res) => {
        this.config = res.data;
      });
    },
    getArea() {
      this.$post("index/area").then((res) => {
        this.area = res.data;
      });
    },
    handleChange(e) {
      this.form.work_area = e.join("/");
    },
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$emit("onSubmit", this.form);
        } else {
          return false;
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  padding: 30px;
  max-width: 500px;
  margin: 0 auto;
}
.bottom {
  display: flex;
  justify-content: center;
  .btn {
    background: #fff;
    border-radius: 4px;
    border: 1px solid #cccccc;
    line-height: 40px;
    text-align: center;
    width: 110px;
    text-align: center;
    cursor: pointer;
    margin: 0 20px;
  }
  .submit {
    border: none;
    background: linear-gradient(-89deg, #ef3e91, #f4743c);
    color: #fff;
  }
}
</style>
